package com.lin.utils;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import u.aly.cu;

import com.lin.bean.NamePingyinUnits;
import com.lin.bean.PingLunBean;
import com.lin.bean.PingyinUnitIndex;
import com.lin.bean.ZanList;
import com.t9search.model.PinyinUnit;
import com.t9search.model.T9PinyinUnit;
import com.yunfeng.supercall.bean.FriendsShareBean;
import com.yunfeng.supercall.bean.PhoneContactsBean;
import com.yunfeng.supercall.bean.RecentCallsBean;
import com.yunfeng.supercall.bean.SuperFriendsBean;

import android.content.ContentValues;
import android.content.Context;  
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;  
import android.database.sqlite.SQLiteDatabase.CursorFactory;  
import android.database.sqlite.SQLiteOpenHelper;  
import android.util.Log;  

public class DatabaseHelperForChattingMap extends SQLiteOpenHelper{  
	private static final int VERSION = 1;  
	private static final String SWORD="SWORD";  
	public DatabaseHelperForChattingMap(Context context, String name, CursorFactory factory,  
			int version) {  
		super(context, name, factory, version);  

	}  
	public DatabaseHelperForChattingMap(Context context,String name){  
		this(context,name,VERSION);  
	}  
	public DatabaseHelperForChattingMap(Context context,String name,int version){  
		this(context, name,null,version);  
	}  
	
	static DatabaseHelperForChattingMap mDatabaseHelperForChattingMap;

	public static DatabaseHelperForChattingMap getDatabaseHelperForChattingMap(Context context,String name,int version) {
		if(mDatabaseHelperForChattingMap==null) {
			mDatabaseHelperForChattingMap=new DatabaseHelperForChattingMap(context, name, version);
		}
		return mDatabaseHelperForChattingMap;
	}
	public void onCreate(SQLiteDatabase db) {  
		Log.i(SWORD,"create a Database");
		//聊天信息
		String sql = "CREATE TABLE if not exists UCSMessage (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, idr varchar, chatType varchar,Userid varchar , content text, msgFrom text, msgId varchar, msgTo varchar, receiveTime varchar, voiceLength varchar, isread varchar, UnreadCount integer DEFAULT 1)";
		db.execSQL(sql);

		sql = "CREATE TABLE if not exists Share (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Img varchar, Shareid varchar,Lng varchar , Lat varchar, Content text, Photo text, Nick_name varchar, Createtime varchar, SuColor varchar, Zannum varchar, Pinglunnum varchar, Userid varchar, ping text, zan text, fromUserId integer, fromOtherId integer)";
		db.execSQL(sql);
		
		sql = "CREATE TABLE if not exists ShareCollection (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Img varchar, Shareid varchar UNIQUE,Lng varchar , Lat varchar, Content text, Photo text, Nick_name varchar, Createtime varchar, SuColor varchar, Zannum varchar, Pinglunnum varchar, Userid varchar, ping text, zan text, fromUserId integer, fromOtherId integer)";
		db.execSQL(sql);

		sql = "CREATE TABLE if not exists UserInfo (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, username text, avatar text, uid text, phone text, UnreadCount integer DEFAULT 1)";
		db.execSQL(sql);
		sql = "CREATE TABLE if not exists SuperFriendsBean (" +
				"`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
				"Address text," +
				" ContactsType text," +
				" isClicked text," +

				"IsFollowers text," +
				" LastChatTime text," +
				" Lat text," +

				"Level text," +
				" Lng text," +
				" MatchKeyWords text," +


				"ListImg text," +
				" NickName text," +
				" Note text," +

				"Onlineday text," +
				" Phone text," +
				" Photo text," +

				"RealName text," +
				"Sex text," +
				"Shareimgs text," +

				"StickyItem text," +
				"Sucolor text," +
				"Suid text," +

				"SuperNumber text," +
				"Tel text," +
				"Type text," +

				"UnreadCount text," +
				"Userid text UNIQUE," +
				"Vo_id text," +
				"callnum text," +
				"WhiteSuperNumber text)";

		db.execSQL(sql);
		
		sql = "CREATE TABLE if not exists RecentCallsBean (" +
				"`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
				"Address text," +
				" ContactsType text," +
				" isClicked text," +

				"IsFollowers text," +
				" LastChatTime text," +
				" Lat text," +

				"Level text," +
				" Lng text," +
				" MatchKeyWords text," +


				"ListImg text," +
				" NickName text," +
				" Note text," +

				"Onlineday text," +
				" Phone text," +
				" Photo text," +

				"RealName text," +
				"Sex text," +
				"Shareimgs text," +

				"StickyItem text," +
				"Sucolor text," +
				"Suid text," +

				"SuperNumber text," +
				"Tel text," +
				"Type text," +

				"UnreadCount text," +
				"Userid text UNIQUE," +
				"Vo_id text," +

"callid text," +
"user1 text ," +
"user2 text," +

"calltime text," +
"state text ," +
"callnum text," +
				
				"WhiteSuperNumber text)";

		db.execSQL(sql);
		

		sql = "CREATE TABLE if not exists FriendsUserInfo (" +
				"`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
				"Address text," +
				" ContactsType text," +
				" isClicked text," +

				"IsFollowers text," +
				" LastChatTime text," +
				" Lat text," +

				"Level text," +
				" Lng text," +
				" MatchKeyWords text," +


				"ListImg text," +
				" NickName text," +
				" Note text," +

				"Onlineday text," +
				" Phone text," +
				" Photo text," +

				"RealName text," +
				"Sex text," +
				"Shareimgs text," +

				"StickyItem text," +
				"Sucolor text," +
				"Suid text," +

				"SuperNumber text," +
				"Tel text," +
				"Type text," +

				"UnreadCount text," +
				"Userid text UNIQUE," +
				"Vo_id text," +

				"WhiteSuperNumber text)";

		db.execSQL(sql);


		//缓存 三张关联一对多表
		sql = "CREATE TABLE if not exists PhoneContactsBeanCache (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, peoplename text, phonenum varchar,contactID varchar UNIQUE)";
		db.execSQL(sql);

		sql = "CREATE TABLE if not exists NamePingyinUnits (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, r_contactID integer, mPinyin integer,mStartPosition integer)";
		db.execSQL(sql);

		//聊天信息
		sql = "CREATE TABLE if not exists PingyinUnitIndex (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, n_id integer, number integer,pingyin varchar)";
		db.execSQL(sql);

	}  

	public PhoneContactsBean getPhoneContactsBean(String id) {
		PhoneContactsBean mBean = new PhoneContactsBean();
		SQLiteDatabase db3 = null;
		db3 = this.getReadableDatabase();
		try {


			Cursor cursor = db3.query("PhoneContactsBeanCache", new String[]{"id" ,"peoplename", "phonenum", "contactID"}, "contactID=?", new String[]{id}, null, null, null);

			if(cursor.moveToNext()){

				int id2 = cursor.getColumnIndex("id");
				int peoplename = cursor.getColumnIndex("peoplename");
				int phonenum = cursor.getColumnIndex("phonenum");
				int contactID = cursor.getColumnIndex("contactID");
				String mcontactID =  cursor.getString(contactID);
				String mphonenum =  cursor.getString(phonenum);
				String mpeoplename =  cursor.getString(peoplename);
				String mid2 =  cursor.getString(id2);
				mBean.setNick_name(mpeoplename);
				mBean.setContactID(mcontactID);
				mBean.setPhone(mphonenum);
				ArrayList<PinyinUnit> mPinyinUnitList = getPinyinUnitList(mid2);
				mBean.setNamePinyinUnits(mPinyinUnitList);
			}

			if(cursor != null) {
				cursor.close();
				cursor = null;
			}
			if(db3 != null) {
				db3.close();
				db3 = null;
			}
		}catch(Exception e) {

		}
		return mBean;
	}


	public ArrayList<PinyinUnit> getPinyinUnitList(String id) {
		ArrayList<PinyinUnit> mList = new ArrayList<PinyinUnit>();
		SQLiteDatabase db3 = null;
		db3 = this.getReadableDatabase();
		Cursor cursor = db3.query("NamePingyinUnits", new String[]{"id" ,"mPinyin", "mStartPosition", "r_contactID"}, "r_contactID=?", new String[]{id}, null, null, null);
		while(cursor.moveToNext()){
			PinyinUnit mPinyinUnit = new PinyinUnit();
			int rid = cursor.getColumnIndex("id");
			int Pinyin = cursor.getColumnIndex("mPinyin");
			int StartPosition = cursor.getColumnIndex("mStartPosition");
			//			int contactID = cursor.getColumnIndex("contactID");
			String mPinyin =  cursor.getString(Pinyin);
			int mStartPosition =  cursor.getInt(StartPosition);
			String mid =  cursor.getString(rid);
			mPinyinUnit.setPinyin(false); //????????????
			mPinyinUnit.setStartPosition(mStartPosition);

			ArrayList<T9PinyinUnit> mList2 = getT9PinyinUnit(mid);

			mPinyinUnit.setStringIndex(mList2);
			//			mPinyinUnit.set
			//			mPinyinUnit.set
			mList.add(mPinyinUnit);
		}
		if(cursor != null) {
			cursor.close();
			cursor = null;
		}
		if(db3 !=null) {
			db3.close();
			db3 = null;
		}

		return mList;
	}


	public ArrayList<T9PinyinUnit> getT9PinyinUnit(String id) {
		ArrayList<T9PinyinUnit> mList = new ArrayList<T9PinyinUnit>();
		SQLiteDatabase db3 = null;
		db3 = this.getReadableDatabase();
		Cursor cursor = db3.query("PingyinUnitIndex", new String[]{"id" ,"n_id", "pingyin", "number"}, "n_id=?", new String[]{id}, null, null, null);
		while(cursor.moveToNext()){
			T9PinyinUnit mPinyinUnit = new T9PinyinUnit();
			//			int id = cursor.getColumnIndex("id");
			int n_id = cursor.getColumnIndex("n_id");
			int number = cursor.getColumnIndex("number");
			int pingyin = cursor.getColumnIndex("pingyin");
			//			int contactID = cursor.getColumnIndex("contactID");
			String mn_id =  cursor.getString(n_id);
			String mnumber =  cursor.getString(number);
			String mpingyin =  cursor.getString(pingyin);

			mPinyinUnit.setNumber(mnumber);
			mPinyinUnit.setPinyin(mpingyin);
			//			mPinyinUnit.set
			//			mPinyinUnit.set
			//			mPinyinUnit.set
			mList.add(mPinyinUnit);
		}
		if(cursor !=null) {
			cursor.close();
			cursor = null;
		}
		if(db3 !=null) {
			db3.close();
			db3 = null;
		}

		return mList;
	}

		
		public ArrayList<PhoneContactsBean> getPhoneContactsBeanCacheList() {
			ArrayList<PhoneContactsBean> mList = new ArrayList<PhoneContactsBean>();

			PhoneContactsBean mBean = new PhoneContactsBean();
			SQLiteDatabase db3 = null;
			db3 = this.getReadableDatabase();
			try {


				Cursor cursor = db3.query("PhoneContactsBeanCache", new String[]{"id" ,"peoplename", "phonenum", "contactID"}, null, null, null, null, null);

				while(cursor.moveToNext()){

					int id2 = cursor.getColumnIndex("id");
					int peoplename = cursor.getColumnIndex("peoplename");
					int phonenum = cursor.getColumnIndex("phonenum");
					int contactID = cursor.getColumnIndex("contactID");
					String mcontactID =  cursor.getString(contactID);
					String mphonenum =  cursor.getString(phonenum);
					String mpeoplename =  cursor.getString(peoplename);
					String mid2 =  cursor.getString(id2);
					mBean.setNick_name(mpeoplename);
					mBean.setContactID(mcontactID);
					mBean.setPhone(mphonenum);
					ArrayList<PinyinUnit> mPinyinUnitList = getPinyinUnitList(mid2);
					mBean.setNamePinyinUnits(mPinyinUnitList);
					mList.add(mBean);
				}

				if(cursor != null) {
					cursor.close();
					cursor = null;
				}
				if(db3 != null) {
					db3.close();
					db3 = null;
				}
			}catch(Exception e) {

			}
			return mList;
		}



	public long insertPhoneContactsBeanCacheList(ArrayList<PhoneContactsBean> mBeanList) {
		long i  = -1;
		SQLiteDatabase db3 = null;
		try {
			db3 = this.getWritableDatabase();
			
			db3.beginTransaction();
			for(Iterator<PhoneContactsBean> iterator=mBeanList.iterator();iterator.hasNext();) {
				PhoneContactsBean mBean = iterator.next();
				ContentValues contentValues = new ContentValues();
				contentValues.put("peoplename",mBean.getNick_name()+"");
				contentValues.put("phonenum",mBean.getPhone() + "");
				contentValues.put("contactID",mBean.getContactID() + "");
				i = db3.insertWithOnConflict("PhoneContactsBeanCache", null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
				List<PinyinUnit> mList = mBean.getNamePinyinUnits();
				insertNamePingyinUnitsList(db3, mBean.getNamePinyinUnits(), i + "");
			}

			db3.setTransactionSuccessful();        //����������ɹ��������û��Զ��ع����ύ
			db3.endTransaction();        //�������
		} catch(Exception e) {
			e.printStackTrace();
		} finally {
			if(db3 != null) {
				db3.close();
				db3 = null;
			}
		}
		return i;
	}

	public long insertPhoneContactsBeanCache(PhoneContactsBean mBean) {
		long i  = -1;
		SQLiteDatabase db3 = null;
		try {
			db3 = this.getWritableDatabase();  

			ContentValues contentValues = new ContentValues();
			contentValues.put("peoplename",mBean.getNick_name()+"");
			contentValues.put("phonenum",mBean.getPhone() + "");
			contentValues.put("contactID",mBean.getContactID() + "");
			i = db3.insert("PhoneContactsBeanCache", null, contentValues);
			List<PinyinUnit> mList = mBean.getNamePinyinUnits();
			insertNamePingyinUnitsList(db3, mBean.getNamePinyinUnits(), i + "");

		} catch(Exception e) {
			e.printStackTrace();
		} finally {
			if(db3 != null) {
				db3.close();
				db3 = null;
			}
		}
		return i;
	}

	public long insertPhoneContactsBeanCache(ArrayList<PhoneContactsBean> mBeanList) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();
			db3.beginTransaction();
			for(Iterator<PhoneContactsBean> iterator=mBeanList.iterator();iterator.hasNext();) {
				PhoneContactsBean mBean = iterator.next();
				ContentValues contentValues = new ContentValues();
				contentValues.put("peoplename",mBean.getNick_name()+"");
				contentValues.put("phonenum",mBean.getPhone() + "");
				contentValues.put("contactID",mBean.getContactsType() + "");
				i = db3.insert("FriendsUserInfo", null, contentValues);
			}
			db3.setTransactionSuccessful();        //����������ɹ��������û��Զ��ع����ύ
			db3.endTransaction();        //�������
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}

	public long insertNamePingyinUnits(NamePingyinUnits mBean) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();  

			ContentValues contentValues = new ContentValues();
			contentValues.put("r_contactID",mBean.getR_contactID()+"");
			contentValues.put("Pinyin",mBean.getmPinyin() + "");
			contentValues.put("StartPosition",mBean.getStartPosition() + "");
			i = db3.insert("FriendsUserInfo", null, contentValues);

			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}

	public long insertNamePingyinUnitsList(SQLiteDatabase db3, List<PinyinUnit> mBeanList , String r_contactID) {
		long i  = -1;
		//		SQLiteDatabase db3 = null ;
		try {
			//			db3 = this.getWritableDatabase();  

			for(Iterator<PinyinUnit> iterator=mBeanList.iterator();iterator.hasNext();) {
				PinyinUnit mBean = iterator.next();
				ContentValues contentValues = new ContentValues();
				contentValues.put("r_contactID",r_contactID+"");
				//				contentValues.put("Pinyin",mBean.get + "");
				//				T9PinyinUnit mBean.getT9PinyinUnitIndex()
				contentValues.put("mPinyin",1+"");
				contentValues.put("mStartPosition",mBean.getStartPosition() + "");
				i = db3.insert("NamePingyinUnits", null, contentValues);
				insertPingyinUnitList(db3, mBean.getT9PinyinUnitIndex(), i + "");
			}

		} catch(Exception e) {
			e.printStackTrace();
		} finally {
			//			if(db3 != null) {
			//				db3.close();
			//				db3 = null;
			//			}
		}
		return i;
	}



	public long insertPingyinUnitIndex(T9PinyinUnit mBean, String n_id) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();  

			ContentValues contentValues = new ContentValues();
			contentValues.put("n_id",n_id+"");
			contentValues.put("number",mBean.getNumber() + "");
			contentValues.put("pingyin",mBean.getPinyin() + "");
			i = db3.insert("PingyinUnitIndex", null, contentValues);

			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}

	public long insertPingyinUnitList(SQLiteDatabase db3, List<T9PinyinUnit> mBeanList, String n_id) {
		long i  = -1;
		//		SQLiteDatabase db3 ;
		try {
			db3 = this.getWritableDatabase();  
			for(Iterator<T9PinyinUnit> iterator=mBeanList.iterator();iterator.hasNext();) {
				T9PinyinUnit mBean = iterator.next();
				ContentValues contentValues = new ContentValues();
				contentValues.put("n_id",n_id+"");
				contentValues.put("number",mBean.getNumber() + "");
				contentValues.put("pingyin",mBean.getPinyin() + "");
				i = db3.insert("PingyinUnitIndex", null, contentValues);
			}

			/*	if(db3 != null) {
				db3.close();
			}*/
		} catch(Exception e) {

		}
		return i;
	}



	public long getReadCount(String Userid) {
		int UnreadCount = 0;
		try {
			SQLiteDatabase db3 = this.getReadableDatabase();
			Cursor cursor2 = db3.query("SuperFriendsBean",  new String[] {"id", "UnreadCount"}, "Userid=?", new String[]{Userid}, null, null, null);
			//利用游标遍历所有数据对象  
			if(cursor2.moveToNext()){
				//			int id =  cursor2.getInt(cursor2.getColumnIndex("id"));
				UnreadCount =  cursor2.getInt(cursor2.getColumnIndex("UnreadCount"));
				/*UnreadCount ++;
			ContentValues contentValues = new ContentValues();
			contentValues.put("UnreadCount",UnreadCount+"");

			SQLiteDatabase db = this.getWritableDatabase();
			db.update("UCSMessage", contentValues, "id=?", new String[]{id + ""});
			if(db != null) {
				db.close();
				db = null;
			}*/
			}
			if(cursor2 != null) {
				cursor2.close();
				cursor2 = null;
			}
			if(db3 != null) {
				db3.close();
				db3 = null;
			}
		} catch(Exception e) {

		}
		return UnreadCount;
	}


	public long incReadCount(String Userid) {
		int UnreadCount = 0;
		try {
			SQLiteDatabase db3 = this.getReadableDatabase();
			Cursor cursor2 = db3.query("SuperFriendsBean",  new String[] {"id", "UnreadCount"}, "Userid=?", new String[]{Userid}, null, null, null);
			//利用游标遍历所有数据对象  
			while(cursor2.moveToNext()){
				int id =  cursor2.getInt(cursor2.getColumnIndex("id"));
				UnreadCount =  cursor2.getInt(cursor2.getColumnIndex("UnreadCount"));
				UnreadCount ++;
				ContentValues contentValues = new ContentValues();
				contentValues.put("UnreadCount",UnreadCount+"");

				SQLiteDatabase db = this.getWritableDatabase();
				int result = db.update("SuperFriendsBean", contentValues, "Userid=?", new String[]{Userid + ""});
				if(db != null) {
					db.close();
					db = null;
				}
			}
			if(cursor2 != null) {
				cursor2.close();
				cursor2 = null;
			}
			if(db3 != null) {
				db3.close();
				db3 = null;
			}
		} catch(Exception e) {

		}
		return UnreadCount;
	}

	public long resetZeroUCSMessage(String id) {
		int UnreadCount = 0;
		try {
			SQLiteDatabase db3 = this.getReadableDatabase();
			Cursor cursor2 = db3.query("UCSMessage",  new String[] {"id", "isread"}, "id=?", new String[]{id}, null, null, null);
			//利用游标遍历所有数据对象  
			while(cursor2.moveToNext()){
				ContentValues contentValues = new ContentValues();
				contentValues.put("isread",0+"");

				SQLiteDatabase db = this.getWritableDatabase();
				int result = db.update("UCSMessage", contentValues, "id=?", new String[]{id + ""});
				if(db != null) {
					db.close();
					db = null;
				}
			}
			if(cursor2 != null) {
				cursor2.close();
				cursor2 = null;
			}
			if(db3 != null) {
				db3.close();
				db3 = null;
			}
		} catch(Exception e) {

		}
		return UnreadCount;
	}

	public long resetZero(String Userid) {
		int UnreadCount = 0;
		SQLiteDatabase db3 = this.getReadableDatabase();
		Cursor cursor2 = db3.query("SuperFriendsBean",  new String[] {"id", "UnreadCount"}, "Userid=?", new String[]{Userid}, null, null, null);
		//利用游标遍历所有数据对象  
		while(cursor2.moveToNext()){
			int id =  cursor2.getInt(cursor2.getColumnIndex("id"));
			UnreadCount =  cursor2.getInt(cursor2.getColumnIndex("UnreadCount"));
			ContentValues contentValues = new ContentValues();
			contentValues.put("UnreadCount",0+"");

			SQLiteDatabase db = this.getWritableDatabase();
			int result = db.update("SuperFriendsBean", contentValues, "Userid=?", new String[]{Userid + ""});
			if(db != null) {
				db.close();
				db = null;
			}
		}
		if(cursor2 != null) {
			cursor2.close();
			cursor2 = null;
		}
		if(db3 != null) {
			db3.close();
			db3 = null;
		}

		return UnreadCount;
	}


	public ArrayList<SuperFriendsBean> getFriendsUserInfoList() {
		ArrayList<SuperFriendsBean> mList = new ArrayList<SuperFriendsBean>();
		try {


			SQLiteDatabase db7 = this.getReadableDatabase();  
			//创建游标对象  
			Cursor cursor2 = db7.query("FriendsUserInfo",  new String[] {"Address", "ContactsType","isClicked", "IsFollowers", "LastChatTime", "Lat", "Level", "Lng", "MatchKeyWords", "ListImg", "NickName", "Note", "Onlineday", "Phone", "Photo", "RealName", "Sex", "Shareimgs", "StickyItem", "Sucolor", "Suid","SuperNumber","Tel","Type","UnreadCount", "Userid", "Vo_id", "WhiteSuperNumber"}, null, null, null, null, null);
			//利用游标遍历所有数据对象  

			while(cursor2.moveToNext()){
				String Address =  cursor2.getString(cursor2.getColumnIndex("Address"));
				String ContactsType =  cursor2.getString(cursor2.getColumnIndex("ContactsType"));
				String isClicked =  cursor2.getString(cursor2.getColumnIndex("isClicked"));

				String IsFollowers =  cursor2.getString(cursor2.getColumnIndex("IsFollowers"));
				String LastChatTime =  cursor2.getString(cursor2.getColumnIndex("LastChatTime"));
				String Lat =  cursor2.getString(cursor2.getColumnIndex("Lat"));

				String Level =  cursor2.getString(cursor2.getColumnIndex("Level"));
				String Lng =  cursor2.getString(cursor2.getColumnIndex("Lng"));
				String MatchKeyWords =  cursor2.getString(cursor2.getColumnIndex("MatchKeyWords"));

				String ListImg =  cursor2.getString(cursor2.getColumnIndex("ListImg"));
				String NickName =  cursor2.getString(cursor2.getColumnIndex("NickName"));
				String Note =  cursor2.getString(cursor2.getColumnIndex("Note"));

				String Onlineday =  cursor2.getString(cursor2.getColumnIndex("Onlineday"));
				String Phone =  cursor2.getString(cursor2.getColumnIndex("Phone"));
				String Photo =  cursor2.getString(cursor2.getColumnIndex("Photo"));

				String RealName =  cursor2.getString(cursor2.getColumnIndex("RealName"));
				String Sex =  cursor2.getString(cursor2.getColumnIndex("Sex"));
				String Shareimgs =  cursor2.getString(cursor2.getColumnIndex("Shareimgs"));

				String StickyItem =  cursor2.getString(cursor2.getColumnIndex("StickyItem"));
				String Sucolor =  cursor2.getString(cursor2.getColumnIndex("Sucolor"));
				String Suid =  cursor2.getString(cursor2.getColumnIndex("Suid"));

				String SuperNumber =  cursor2.getString(cursor2.getColumnIndex("SuperNumber"));
				String Tel =  cursor2.getString(cursor2.getColumnIndex("Tel"));
				String Type =  cursor2.getString(cursor2.getColumnIndex("Type"));

				String UnreadCount =  cursor2.getString(cursor2.getColumnIndex("UnreadCount"));
				String Userid =  cursor2.getString(cursor2.getColumnIndex("Userid"));
				String Vo_id =  cursor2.getString(cursor2.getColumnIndex("Vo_id"));


				String WhiteSuperNumber =  cursor2.getString(cursor2.getColumnIndex("WhiteSuperNumber"));

				SuperFriendsBean mBean = new SuperFriendsBean();
				mBean.setAddress(Address);
				mBean.setIsClicked(Integer.parseInt(isClicked));
				mBean.setIsfollower(Integer.parseInt(IsFollowers));
				mBean.setLastChatTime(Long.parseLong(LastChatTime));
				mBean.setLat(Double.parseDouble(Lat));
				mBean.setLevel(Integer.parseInt(Level));
				mBean.setLng(Double.parseDouble(Lng));
				mBean.setMatchKeywords(MatchKeyWords);
				mBean.setNick_name(NickName);
				mBean.setNote(Note);
				mBean.setOnlineday(Onlineday);
				mBean.setPhone(Phone);
				mBean.setPhoto(Photo);
				mBean.setReal_name(RealName);
				mBean.setSex(Integer.parseInt(Sex));
				mBean.setShareimgs(Shareimgs);
				mBean.setSucolor(Integer.parseInt(Sucolor));
				mBean.setSuid(Suid);
				mBean.setSuperNumber(SuperNumber);
				mBean.setTel(Tel);
				mBean.setType(Integer.parseInt(Type));
				mBean.setUnreadCount(Integer.parseInt(UnreadCount));
				mBean.setUserid(Integer.parseInt(Userid));
				mBean.setVo_id(Vo_id);
				mList.add(mBean);
			}		
		} catch(Exception e) {

		}
		return mList;
	}

	
	
	public ArrayList<RecentCallsBean> getRecentCallsBeanList() {
		ArrayList<RecentCallsBean> mList = new ArrayList<RecentCallsBean>();
		try {


			SQLiteDatabase db7 = this.getReadableDatabase();  
			//创建游标对象  
			Cursor cursor2 = db7.query("RecentCallsBean",  new String[] {"Address", "ContactsType","isClicked", "IsFollowers", "LastChatTime", "Lat", "Level", "Lng", "MatchKeyWords", "ListImg", "NickName", "Note", "Onlineday", "Phone", "Photo", "RealName", "Sex", "Shareimgs", "StickyItem", "Sucolor", "Suid","SuperNumber","Tel","Type","UnreadCount", "Userid", "Vo_id", "WhiteSuperNumber", "callid", "user1", "user2", "calltime", "state", "callnum"}, null, null, null, null, null);
			//利用游标遍历所有数据对象  

			while(cursor2.moveToNext()){
				String Address =  cursor2.getString(cursor2.getColumnIndex("Address"));
				String ContactsType =  cursor2.getString(cursor2.getColumnIndex("ContactsType"));
				String isClicked =  cursor2.getString(cursor2.getColumnIndex("isClicked"));

				String IsFollowers =  cursor2.getString(cursor2.getColumnIndex("IsFollowers"));
				String LastChatTime =  cursor2.getString(cursor2.getColumnIndex("LastChatTime"));
				String Lat =  cursor2.getString(cursor2.getColumnIndex("Lat"));

				String Level =  cursor2.getString(cursor2.getColumnIndex("Level"));
				String Lng =  cursor2.getString(cursor2.getColumnIndex("Lng"));
				String MatchKeyWords =  cursor2.getString(cursor2.getColumnIndex("MatchKeyWords"));

				String ListImg =  cursor2.getString(cursor2.getColumnIndex("ListImg"));
				String NickName =  cursor2.getString(cursor2.getColumnIndex("NickName"));
				String Note =  cursor2.getString(cursor2.getColumnIndex("Note"));

				String Onlineday =  cursor2.getString(cursor2.getColumnIndex("Onlineday"));
				String Phone =  cursor2.getString(cursor2.getColumnIndex("Phone"));
				String Photo =  cursor2.getString(cursor2.getColumnIndex("Photo"));

				String RealName =  cursor2.getString(cursor2.getColumnIndex("RealName"));
				String Sex =  cursor2.getString(cursor2.getColumnIndex("Sex"));
				String Shareimgs =  cursor2.getString(cursor2.getColumnIndex("Shareimgs"));

				String StickyItem =  cursor2.getString(cursor2.getColumnIndex("StickyItem"));
				String Sucolor =  cursor2.getString(cursor2.getColumnIndex("Sucolor"));
				String Suid =  cursor2.getString(cursor2.getColumnIndex("Suid"));

				String SuperNumber =  cursor2.getString(cursor2.getColumnIndex("SuperNumber"));
				String Tel =  cursor2.getString(cursor2.getColumnIndex("Tel"));
				String Type =  cursor2.getString(cursor2.getColumnIndex("Type"));

				String UnreadCount =  cursor2.getString(cursor2.getColumnIndex("UnreadCount"));
				String Userid =  cursor2.getString(cursor2.getColumnIndex("Userid"));
				String Vo_id =  cursor2.getString(cursor2.getColumnIndex("Vo_id"));

				String callid =  cursor2.getString(cursor2.getColumnIndex("callid"));
				String user1 =  cursor2.getString(cursor2.getColumnIndex("user1"));
				String user2 =  cursor2.getString(cursor2.getColumnIndex("user2"));

				String calltime =  cursor2.getString(cursor2.getColumnIndex("calltime"));
				String state =  cursor2.getString(cursor2.getColumnIndex("state"));
				String callnum =  cursor2.getString(cursor2.getColumnIndex("callnum"));

				

				String WhiteSuperNumber =  cursor2.getString(cursor2.getColumnIndex("WhiteSuperNumber"));

				RecentCallsBean mBean = new RecentCallsBean();
				mBean.setCallid(callid);
				mBean.setUser1(Integer.parseInt(user1));
				mBean.setUser2(Integer.parseInt(user2));
				
				mBean.setCalltime(calltime);
				mBean.setState(Integer.parseInt(state));
				mBean.setCallnum(Integer.parseInt(callnum));
				
				mBean.setAddress(Address);
				mBean.setIsClicked(Integer.parseInt(isClicked));
				mBean.setIsfollower(Integer.parseInt(IsFollowers));
				mBean.setLastChatTime(Long.parseLong(LastChatTime));
				mBean.setLat(Double.parseDouble(Lat));
				mBean.setLevel(Integer.parseInt(Level));
				mBean.setLng(Double.parseDouble(Lng));
				mBean.setMatchKeywords(MatchKeyWords);
				mBean.setNick_name(NickName);
				mBean.setNote(Note);
				mBean.setOnlineday(Onlineday);
				mBean.setPhone(Phone);
				mBean.setPhoto(Photo);
				mBean.setReal_name(RealName);
				mBean.setSex(Integer.parseInt(Sex));
				mBean.setShareimgs(Shareimgs);
				mBean.setSucolor(Integer.parseInt(Sucolor));
				mBean.setSuid(Suid);
				mBean.setSuperNumber(SuperNumber);
				mBean.setTel(Tel);
				mBean.setType(Integer.parseInt(Type));
				mBean.setUnreadCount(Integer.parseInt(UnreadCount));
				mBean.setUserid(Integer.parseInt(Userid));
				mBean.setVo_id(Vo_id);
				mList.add(mBean);
				
				Log.i("tag5", "success");

			}		
		} catch(Exception e) {
			e.printStackTrace();
		}
		return mList;
	}

	public long insertSuperFrined2(ArrayList<RecentCallsBean> mList) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();
			db3.beginTransaction();
			for(Iterator<RecentCallsBean> iterator=mList.iterator();iterator.hasNext();) {
				RecentCallsBean mBean = iterator.next();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Address",mBean.getAddress()+"");
				contentValues.put("ContactsType",mBean.getContactsType()+"");
				contentValues.put("isClicked",mBean.getIsClicked()+"");
				contentValues.put("IsFollowers",mBean.getIsfollower()+"");
				contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Level",mBean.getLevel()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
				contentValues.put("ListImg",mBean.getmListImg()+"");
				contentValues.put("NickName",mBean.getNick_name()+"");
				contentValues.put("Note",mBean.getNote()+"");
				contentValues.put("Onlineday",mBean.getOnlineday()+"");
				contentValues.put("Phone",mBean.getPhone()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("RealName",mBean.getReal_name()+"");
				contentValues.put("Sex",mBean.getSex()+"");
				contentValues.put("Shareimgs",mBean.getShareimgs()+"");
				contentValues.put("StickyItem",mBean.getStickyItem()+"");
				contentValues.put("Sucolor",mBean.getSucolor()+"");
				contentValues.put("Suid",mBean.getSuid()+"");
				contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
				contentValues.put("Tel",mBean.getTel()+"");
				contentValues.put("Type",mBean.getType()+"");
				contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("Vo_id",mBean.getVo_id() + "");
				contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
				
				contentValues.put("callid",mBean.getCallid()+"");
				contentValues.put("user1",mBean.getUser1()+"");
				contentValues.put("user2",mBean.getUser2()+"");
				contentValues.put("calltime",mBean.getCalltime() + "");
				contentValues.put("state",mBean.getState() + "");
				contentValues.put("callnum",mBean.getCallnum() + "");
				
				i = db3.insert("SuperFriendsBean", null, contentValues);
			}
			db3.setTransactionSuccessful();        //����������ɹ��������û��Զ��ع����ύ
			db3.endTransaction();        //�������
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}


	

	
	public long insertSuperFriendsBean(SuperFriendsBean mBean) {
	long i  = -1;
	try {
		SQLiteDatabase db3 = this.getWritableDatabase();
		db3.beginTransaction();

			ContentValues contentValues = new ContentValues();
			contentValues.put("Address",mBean.getAddress()+"");
			contentValues.put("ContactsType",mBean.getContactsType()+"");
			contentValues.put("isClicked",mBean.getIsClicked()+"");
			contentValues.put("IsFollowers",mBean.getIsfollower()+"");
			contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
			contentValues.put("Lat",mBean.getLat()+"");
			contentValues.put("Level",mBean.getLevel()+"");
			contentValues.put("Lng",mBean.getLng()+"");
			contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
			contentValues.put("ListImg",mBean.getmListImg()+"");
			contentValues.put("NickName",mBean.getNick_name()+"");
			contentValues.put("Note",mBean.getNote()+"");
			contentValues.put("Onlineday",mBean.getOnlineday()+"");
			contentValues.put("Phone",mBean.getPhone()+"");
			contentValues.put("Photo",mBean.getPhoto()+"");
			contentValues.put("RealName",mBean.getReal_name()+"");
			contentValues.put("Sex",mBean.getSex()+"");
			contentValues.put("Shareimgs",mBean.getShareimgs()+"");
			contentValues.put("StickyItem",mBean.getStickyItem()+"");
			contentValues.put("Sucolor",mBean.getSucolor()+"");
			contentValues.put("Suid",mBean.getSuid()+"");
			contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
			contentValues.put("Tel",mBean.getTel()+"");
			contentValues.put("Type",mBean.getType()+"");
			contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
			contentValues.put("Userid",mBean.getUserid()+"");
			contentValues.put("Vo_id",mBean.getVo_id() + "");
			contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
			
			
			i = db3.insert("SuperFriendsBean", null, contentValues);
		db3.setTransactionSuccessful();        //����������ɹ��������û��Զ��ع����ύ
		db3.endTransaction();        //�������
		if(db3 != null) {
			db3.close();
		}
	} catch(Exception e) {

	}
	return i;
}
	
		public long insertSuperFriendInfo(RecentCallsBean mBean) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();
			db3.beginTransaction();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Address",mBean.getAddress()+"");
				contentValues.put("ContactsType",mBean.getContactsType()+"");
				contentValues.put("isClicked",mBean.getIsClicked()+"");
				contentValues.put("IsFollowers",mBean.getIsfollower()+"");
				contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Level",mBean.getLevel()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
				contentValues.put("ListImg",mBean.getmListImg()+"");
				contentValues.put("NickName",mBean.getNick_name()+"");
				contentValues.put("Note",mBean.getNote()+"");
				contentValues.put("Onlineday",mBean.getOnlineday()+"");
				contentValues.put("Phone",mBean.getPhone()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("RealName",mBean.getReal_name()+"");
				contentValues.put("Sex",mBean.getSex()+"");
				contentValues.put("Shareimgs",mBean.getShareimgs()+"");
				contentValues.put("StickyItem",mBean.getStickyItem()+"");
				contentValues.put("Sucolor",mBean.getSucolor()+"");
				contentValues.put("Suid",mBean.getSuid()+"");
				contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
				contentValues.put("Tel",mBean.getTel()+"");
				contentValues.put("Type",mBean.getType()+"");
				contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("Vo_id",mBean.getVo_id() + "");
				contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
				
				contentValues.put("callid",mBean.getCallid()+"");
				contentValues.put("user1",mBean.getUser1()+"");
				contentValues.put("user2",mBean.getUser2()+"");
				contentValues.put("calltime",mBean.getCalltime() + "");
				contentValues.put("state",mBean.getState() + "");
				contentValues.put("callnum",mBean.getCallnum() + "");
				
				i = db3.insert("SuperFriendsBean", null, contentValues);
			db3.setTransactionSuccessful();        //����������ɹ��������û��Զ��ع����ύ
			db3.endTransaction();        //�������
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}

		
		
	public long insertFriendsBeanInfo(SuperFriendsBean mBean) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();  

			ContentValues contentValues = new ContentValues();
			contentValues.put("Address",mBean.getAddress()+"");
			contentValues.put("ContactsType",mBean.getContactsType()+"");
			contentValues.put("isClicked",mBean.getIsClicked()+"");
			contentValues.put("IsFollowers",mBean.getIsfollower()+"");
			contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
			contentValues.put("Lat",mBean.getLat()+"");
			contentValues.put("Level",mBean.getLevel()+"");
			contentValues.put("Lng",mBean.getLng()+"");
			contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
			contentValues.put("ListImg",mBean.getmListImg()+"");
			contentValues.put("NickName",mBean.getNick_name()+"");
			contentValues.put("Note",mBean.getNote()+"");
			contentValues.put("Onlineday",mBean.getOnlineday()+"");
			contentValues.put("Phone",mBean.getPhone()+"");
			contentValues.put("Photo",mBean.getPhoto()+"");
			contentValues.put("RealName",mBean.getReal_name()+"");
			contentValues.put("Sex",mBean.getSex()+"");
			contentValues.put("Shareimgs",mBean.getShareimgs()+"");
			contentValues.put("StickyItem",mBean.getStickyItem()+"");
			contentValues.put("Sucolor",mBean.getSucolor()+"");
			contentValues.put("Suid",mBean.getSuid()+"");
			contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
			contentValues.put("Tel",mBean.getTel()+"");
			contentValues.put("Type",mBean.getType()+"");
			contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
			contentValues.put("Userid",mBean.getUserid()+"");
			contentValues.put("Vo_id",mBean.getVo_id() + "");
			contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
			i = db3.insert("FriendsUserInfo", null, contentValues);

			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}


	public long insertSuperFrined(SuperFriendsBean mBean) {
		long i  = -1;	
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();  

			ContentValues contentValues = new ContentValues();
			contentValues.put("Address",mBean.getAddress()+"");
			contentValues.put("ContactsType",mBean.getContactsType()+"");
			contentValues.put("isClicked",mBean.getIsClicked()+"");
			contentValues.put("IsFollowers",mBean.getIsfollower()+"");
			contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
			contentValues.put("Lat",mBean.getLat()+"");
			contentValues.put("Level",mBean.getLevel()+"");
			contentValues.put("Lng",mBean.getLng()+"");
			contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
			contentValues.put("ListImg",mBean.getmListImg()+"");
			contentValues.put("NickName",mBean.getNick_name()+"");
			contentValues.put("Note",mBean.getNote()+"");
			contentValues.put("Onlineday",mBean.getOnlineday()+"");
			contentValues.put("Phone",mBean.getPhone()+"");
			contentValues.put("Photo",mBean.getPhoto()+"");
			contentValues.put("RealName",mBean.getReal_name()+"");
			contentValues.put("Sex",mBean.getSex()+"");
			contentValues.put("Shareimgs",mBean.getShareimgs()+"");
			contentValues.put("StickyItem",mBean.getStickyItem()+"");
			contentValues.put("Sucolor",mBean.getSucolor()+"");
			contentValues.put("Suid",mBean.getSuid()+"");
			contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
			contentValues.put("Tel",mBean.getTel()+"");
			contentValues.put("Type",mBean.getType()+"");
			contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
			contentValues.put("Userid",mBean.getUserid()+"");
			contentValues.put("Vo_id",mBean.getVo_id() + "");
			contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
			i = db3.insert("SuperFriendsBean", null, contentValues);

			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}

		return i;
	}


	public long insertFriendsShareBeanList(ArrayList<FriendsShareBean> mList, String fromUserId, String fromOtherId) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();

			for(Iterator<FriendsShareBean> iterator=mList.iterator();iterator.hasNext();) {
				FriendsShareBean mBean = iterator.next();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Img",mBean.getImg()+"");
				contentValues.put("Shareid",mBean.getShareid()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Content",mBean.getContent()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("Nick_name",mBean.getNick_name()+"");
				contentValues.put("Createtime",mBean.getCreatetime()+"");
				contentValues.put("SuColor",mBean.getSuColor()+"");
				contentValues.put("Zannum",mBean.getZannum()+"");
				contentValues.put("Pinglunnum",mBean.getPinglunlist()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("ping",mBean.getPinglunlist()+"");
				contentValues.put("zan",mBean.getZanlist()+"");
				contentValues.put("fromUserId",fromUserId+"");
				contentValues.put("fromOtherId",fromOtherId+"");

				i = db3.insert("Share", null, contentValues);
				Log.i("tag3", i + "result");
			}
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}


	public long insertFriendsShareBeanListCollection(ArrayList<FriendsShareBean> mList, String fromUserId) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();

			for(Iterator<FriendsShareBean> iterator=mList.iterator();iterator.hasNext();) {
				FriendsShareBean mBean = iterator.next();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Img",mBean.getImg()+"");
				contentValues.put("Shareid",mBean.getShareid()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Content",mBean.getContent()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("Nick_name",mBean.getNick_name()+"");
				contentValues.put("Createtime",mBean.getCreatetime()+"");
				contentValues.put("SuColor",mBean.getSuColor()+"");
				contentValues.put("Zannum",mBean.getZannum()+"");
				contentValues.put("Pinglunnum",mBean.getPinglunlist()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("ping",mBean.getPinglunlist()+"");
				contentValues.put("zan",mBean.getZanlist()+"");
				contentValues.put("fromUserId",fromUserId+"");
				contentValues.put("fromOtherId",fromUserId+"");

				i = db3.insert("ShareCollection", null, contentValues);
				Log.i("tag3", i + "result");
			}
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}



	public long insertSuperFriendsUserInfo(ArrayList<SuperFriendsBean> mList) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();

			for(Iterator<SuperFriendsBean> iterator=mList.iterator();iterator.hasNext();) {
				SuperFriendsBean mBean = iterator.next();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Address",mBean.getAddress()+"");
				contentValues.put("ContactsType",mBean.getContactsType()+"");
				contentValues.put("isClicked",mBean.getIsClicked()+"");
				contentValues.put("IsFollowers",mBean.getIsfollower()+"");
				contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Level",mBean.getLevel()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
				contentValues.put("ListImg",mBean.getmListImg()+"");
				contentValues.put("NickName",mBean.getNick_name()+"");
				contentValues.put("Note",mBean.getNote()+"");
				contentValues.put("Onlineday",mBean.getOnlineday()+"");
				contentValues.put("Phone",mBean.getPhone()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("RealName",mBean.getReal_name()+"");
				contentValues.put("Sex",mBean.getSex()+"");
				contentValues.put("Shareimgs",mBean.getShareimgs()+"");
				contentValues.put("StickyItem",mBean.getStickyItem()+"");
				contentValues.put("Sucolor",mBean.getSucolor()+"");
				contentValues.put("Suid",mBean.getSuid()+"");
				contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
				contentValues.put("Tel",mBean.getTel()+"");
				contentValues.put("Type",mBean.getType()+"");
				contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("Vo_id",mBean.getVo_id() + "");
				contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
				//			i = db3.insert("UCSMessage", null, contentValues);
				i = db3.insert("FriendsUserInfo", null, contentValues);

			}
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}

	public long insertSuperFriendsUserInfoFromRecentCallBean(ArrayList<RecentCallsBean> mList) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();

			for(Iterator<RecentCallsBean> iterator=mList.iterator();iterator.hasNext();) {
				RecentCallsBean mBean = iterator.next();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Address",mBean.getAddress()+"");
				contentValues.put("ContactsType",mBean.getContactsType()+"");
				contentValues.put("isClicked",mBean.getIsClicked()+"");
				contentValues.put("IsFollowers",mBean.getIsfollower()+"");
				contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Level",mBean.getLevel()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
				contentValues.put("ListImg",mBean.getmListImg()+"");
				contentValues.put("NickName",mBean.getNick_name()+"");
				contentValues.put("Note",mBean.getNote()+"");
				contentValues.put("Onlineday",mBean.getOnlineday()+"");
				contentValues.put("Phone",mBean.getPhone()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("RealName",mBean.getReal_name()+"");
				contentValues.put("Sex",mBean.getSex()+"");
				contentValues.put("Shareimgs",mBean.getShareimgs()+"");
				contentValues.put("StickyItem",mBean.getStickyItem()+"");
				contentValues.put("Sucolor",mBean.getSucolor()+"");
				contentValues.put("Suid",mBean.getSuid()+"");
				contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
				contentValues.put("Tel",mBean.getTel()+"");
				contentValues.put("Type",mBean.getType()+"");
				contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("Vo_id",mBean.getVo_id() + "");
				contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
				//			i = db3.insert("UCSMessage", null, contentValues);
				i = db3.insert("FriendsUserInfo", null, contentValues);

			}
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}
	
	public ArrayList<FriendsShareBean> getFriendsShareBeanListCollection(String fromUserId) {
		ArrayList<FriendsShareBean> mListFriendsShareBean = new ArrayList<FriendsShareBean>();
		try {
			SQLiteDatabase db7 = this.getReadableDatabase();  
			//创建游标对象  
			Cursor cursor2 = db7.query("ShareCollection",  new String[] {"id", "Img","Shareid", "Lng", "Lat", "Content", "Photo", "Nick_name", "Createtime", "SuColor", "Zannum", "Pinglunnum", "Userid", "ping", "zan"}, "fromUserId=?", new String[] {fromUserId}, null, null, null);
			//利用游标遍历所有数据对象  

			while(cursor2.moveToNext()){
				int id =  cursor2.getInt(cursor2.getColumnIndex("id")); 
				String Img =  cursor2.getString(cursor2.getColumnIndex("Img"));
				String Shareid =  cursor2.getString(cursor2.getColumnIndex("Shareid"));
				String Lng =  cursor2.getString(cursor2.getColumnIndex("Lng"));
				String Lat =  cursor2.getString(cursor2.getColumnIndex("Lat"));
				String Content =  cursor2.getString(cursor2.getColumnIndex("Content"));
				String Photo =  cursor2.getString(cursor2.getColumnIndex("Photo"));
				String Nick_name =  cursor2.getString(cursor2.getColumnIndex("Nick_name"));
				String Createtime =  cursor2.getString(cursor2.getColumnIndex("Createtime"));

				String NickName =  cursor2.getString(cursor2.getColumnIndex("Nick_name"));

				String SuColor =  cursor2.getString(cursor2.getColumnIndex("SuColor"));

				String Zannum =  cursor2.getString(cursor2.getColumnIndex("Zannum"));
				String Pinglunnum =  cursor2.getString(cursor2.getColumnIndex("Pinglunnum"));
				String Userid =  cursor2.getString(cursor2.getColumnIndex("Userid"));

				String ping =  cursor2.getString(cursor2.getColumnIndex("ping"));
				String zan =  cursor2.getString(cursor2.getColumnIndex("zan"));


				FriendsShareBean mBean = new FriendsShareBean();
				mBean.setId(id);
				mBean.setZannum(Zannum);
				mBean.setImg(Img);
				mBean.setShareid(Integer.parseInt(Shareid));
				mBean.setLat(Double.parseDouble(Lat));
				mBean.setLng(Double.parseDouble(Lng));
				mBean.setContent(Content);
				mBean.setNick_name(NickName);
				mBean.setCreatetime(Createtime);
				mBean.setSuColor(Integer.parseInt(SuColor));
				mBean.setCreatetime(Createtime);
				mBean.setPhoto(Photo);
				mBean.setPinglunnum(Pinglunnum);
				mBean.setUserid(Integer.parseInt(Userid));
				mBean.setNick_name(Nick_name);
				if(ping.length() > 3) {
					JSONArray jsonPinglunList;
					try {
						jsonPinglunList = new JSONArray(ping);


						int cpt2 = 0;
						int size2 = jsonPinglunList.length();
						ArrayList<PingLunBean> mList = new ArrayList<PingLunBean>();
						while(cpt2 < size2) {
							JSONObject mJSONItem2 = jsonPinglunList.getJSONObject(cpt2);
							PingLunBean pingLunBean = new PingLunBean();
							pingLunBean.setContent(mJSONItem2.getString("content"));
							pingLunBean.setCreatetime(mJSONItem2.getString("createtime"));
							pingLunBean.setLat(mJSONItem2.getString("lat"));
							pingLunBean.setLng(mJSONItem2.getString("lng"));
							pingLunBean.setNick_name(mJSONItem2.getString("nick_name"));
							pingLunBean.setPhoto(mJSONItem2.getString("photo"));
							pingLunBean.setUserid(mJSONItem2.getString("userid"));
							mList.add(pingLunBean);
							cpt2 ++;
						}
						mBean.setJsonPinglunList(mList);
					} catch (JSONException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}

				try {
					if(zan.length() > 3) {
						JSONArray jsonZanlist = new JSONArray(zan);

						int cpt3 = 0;
						int size3 = jsonZanlist.length();
						ArrayList<ZanList> mZanList = new ArrayList<ZanList>();
						while(cpt3 < size3) {
							JSONObject mJSONItem2 = jsonZanlist.getJSONObject(cpt3);
							ZanList mZan = new ZanList();
							mZan.setNickName(mJSONItem2.getString("nick_name"));
							mZan.setPhoto(mJSONItem2.getString("photo"));
							mZanList.add(mZan);
							cpt3 ++;
						}
						mBean.setmZanList(mZanList);
					}		
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} 
				mListFriendsShareBean.add(mBean);
				Log.i("tag4", mListFriendsShareBean.size() + "");
			}		
		} catch(Exception e) {

		}
		return mListFriendsShareBean;
	}
	

	public ArrayList<FriendsShareBean> getFriendsShareBeanList(String fromUserId, String fromOtherId) {
		ArrayList<FriendsShareBean> mListFriendsShareBean = new ArrayList<FriendsShareBean>();
		try {
			SQLiteDatabase db7 = this.getReadableDatabase();  
			//创建游标对象  
			Cursor cursor2 = db7.query("Share",  new String[] {"id", "Img","Shareid", "Lng", "Lat", "Content", "Photo", "Nick_name", "Createtime", "SuColor", "Zannum", "Pinglunnum", "Userid", "ping", "zan"}, "fromUserId=? AND fromOtherId=?", new String[] {fromUserId, fromOtherId}, null, null, null);
			//利用游标遍历所有数据对象  

			while(cursor2.moveToNext()){
				int id =  cursor2.getInt(cursor2.getColumnIndex("id")); 
				String Img =  cursor2.getString(cursor2.getColumnIndex("Img"));
				String Shareid =  cursor2.getString(cursor2.getColumnIndex("Shareid"));
				String Lng =  cursor2.getString(cursor2.getColumnIndex("Lng"));
				String Lat =  cursor2.getString(cursor2.getColumnIndex("Lat"));
				String Content =  cursor2.getString(cursor2.getColumnIndex("Content"));
				String Photo =  cursor2.getString(cursor2.getColumnIndex("Photo"));
				String Nick_name =  cursor2.getString(cursor2.getColumnIndex("Nick_name"));
				String Createtime =  cursor2.getString(cursor2.getColumnIndex("Createtime"));

				String NickName =  cursor2.getString(cursor2.getColumnIndex("Nick_name"));

				String SuColor =  cursor2.getString(cursor2.getColumnIndex("SuColor"));

				String Zannum =  cursor2.getString(cursor2.getColumnIndex("Zannum"));
				String Pinglunnum =  cursor2.getString(cursor2.getColumnIndex("Pinglunnum"));
				String Userid =  cursor2.getString(cursor2.getColumnIndex("Userid"));

				String ping =  cursor2.getString(cursor2.getColumnIndex("ping"));
				String zan =  cursor2.getString(cursor2.getColumnIndex("zan"));


				FriendsShareBean mBean = new FriendsShareBean();
				mBean.setId(id);
				mBean.setZannum(Zannum);
				mBean.setImg(Img);
				mBean.setShareid(Integer.parseInt(Shareid));
				mBean.setLat(Double.parseDouble(Lat));
				mBean.setLng(Double.parseDouble(Lng));
				mBean.setContent(Content);
				mBean.setNick_name(NickName);
				mBean.setCreatetime(Createtime);
				mBean.setSuColor(Integer.parseInt(SuColor));
				mBean.setCreatetime(Createtime);
				mBean.setPhoto(Photo);
				mBean.setPinglunnum(Pinglunnum);
				mBean.setUserid(Integer.parseInt(Userid));
				mBean.setNick_name(Nick_name);
				if(ping.length() > 3) {
					JSONArray jsonPinglunList;
					try {
						jsonPinglunList = new JSONArray(ping);


						int cpt2 = 0;
						int size2 = jsonPinglunList.length();
						ArrayList<PingLunBean> mList = new ArrayList<PingLunBean>();
						while(cpt2 < size2) {
							JSONObject mJSONItem2 = jsonPinglunList.getJSONObject(cpt2);
							PingLunBean pingLunBean = new PingLunBean();
							pingLunBean.setContent(mJSONItem2.getString("content"));
							pingLunBean.setCreatetime(mJSONItem2.getString("createtime"));
							pingLunBean.setLat(mJSONItem2.getString("lat"));
							pingLunBean.setLng(mJSONItem2.getString("lng"));
							pingLunBean.setNick_name(mJSONItem2.getString("nick_name"));
							pingLunBean.setPhoto(mJSONItem2.getString("photo"));
							pingLunBean.setUserid(mJSONItem2.getString("userid"));
							mList.add(pingLunBean);
							cpt2 ++;
						}
						mBean.setJsonPinglunList(mList);
					} catch (JSONException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}

				try {
					if(zan.length() > 3) {
						JSONArray jsonZanlist = new JSONArray(zan);

						int cpt3 = 0;
						int size3 = jsonZanlist.length();
						ArrayList<ZanList> mZanList = new ArrayList<ZanList>();
						while(cpt3 < size3) {
							JSONObject mJSONItem2 = jsonZanlist.getJSONObject(cpt3);
							ZanList mZan = new ZanList();
							mZan.setNickName(mJSONItem2.getString("nick_name"));
							mZan.setPhoto(mJSONItem2.getString("photo"));
							mZanList.add(mZan);
							cpt3 ++;
						}
						mBean.setmZanList(mZanList);
					}		
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} 
				mListFriendsShareBean.add(mBean);
				Log.i("tag4", mListFriendsShareBean.size() + "");
			}		
		} catch(Exception e) {

		}
		return mListFriendsShareBean;
	}


	public ArrayList<SuperFriendsBean> getSuperFriendsBeanList() {
		ArrayList<SuperFriendsBean> mList = new ArrayList<SuperFriendsBean>();
		try {
			SQLiteDatabase db7 = this.getReadableDatabase();  
			//创建游标对象  
			String name = "name";
			String mSelfCode = "mSelfCode";
			Cursor cursor2 = db7.query("SuperFriendsBean",  new String[] {"Address", "ContactsType","isClicked", "IsFollowers", "LastChatTime", "Lat", "Level", "Lng", "MatchKeyWords", "ListImg", "NickName", "Note", "Onlineday", "Phone", "Photo", "RealName", "Sex", "Shareimgs", "StickyItem", "Sucolor", "Suid","SuperNumber","Tel","Type","UnreadCount", "Userid", "Vo_id", "WhiteSuperNumber"}, null, null, null, null, null);
			//利用游标遍历所有数据对象  

			while(cursor2.moveToNext()){
				String Address =  cursor2.getString(cursor2.getColumnIndex("Address"));
				String ContactsType =  cursor2.getString(cursor2.getColumnIndex("ContactsType"));
				String isClicked =  cursor2.getString(cursor2.getColumnIndex("isClicked"));

				String IsFollowers =  cursor2.getString(cursor2.getColumnIndex("IsFollowers"));
				String LastChatTime =  cursor2.getString(cursor2.getColumnIndex("LastChatTime"));
				String Lat =  cursor2.getString(cursor2.getColumnIndex("Lat"));

				String Level =  cursor2.getString(cursor2.getColumnIndex("Level"));
				String Lng =  cursor2.getString(cursor2.getColumnIndex("Lng"));
				String MatchKeyWords =  cursor2.getString(cursor2.getColumnIndex("MatchKeyWords"));

				String ListImg =  cursor2.getString(cursor2.getColumnIndex("ListImg"));
				String NickName =  cursor2.getString(cursor2.getColumnIndex("NickName"));
				String Note =  cursor2.getString(cursor2.getColumnIndex("Note"));

				String Onlineday =  cursor2.getString(cursor2.getColumnIndex("Onlineday"));
				String Phone =  cursor2.getString(cursor2.getColumnIndex("Phone"));
				String Photo =  cursor2.getString(cursor2.getColumnIndex("Photo"));

				String RealName =  cursor2.getString(cursor2.getColumnIndex("RealName"));
				String Sex =  cursor2.getString(cursor2.getColumnIndex("Sex"));
				String Shareimgs =  cursor2.getString(cursor2.getColumnIndex("Shareimgs"));

				String StickyItem =  cursor2.getString(cursor2.getColumnIndex("StickyItem"));
				String Sucolor =  cursor2.getString(cursor2.getColumnIndex("Sucolor"));
				String Suid =  cursor2.getString(cursor2.getColumnIndex("Suid"));

				String SuperNumber =  cursor2.getString(cursor2.getColumnIndex("SuperNumber"));
				String Tel =  cursor2.getString(cursor2.getColumnIndex("Tel"));
				String Type =  cursor2.getString(cursor2.getColumnIndex("Type"));

				String UnreadCount =  cursor2.getString(cursor2.getColumnIndex("UnreadCount"));
				String Userid =  cursor2.getString(cursor2.getColumnIndex("Userid"));
				String Vo_id =  cursor2.getString(cursor2.getColumnIndex("Vo_id"));


				String WhiteSuperNumber =  cursor2.getString(cursor2.getColumnIndex("WhiteSuperNumber"));

				SuperFriendsBean mBean = new SuperFriendsBean();
				mBean.setAddress(Address);
				mBean.setIsClicked(Integer.parseInt(isClicked));
				mBean.setIsfollower(Integer.parseInt(IsFollowers));
				mBean.setLastChatTime(Long.parseLong(LastChatTime));
				mBean.setLat(Double.parseDouble(Lat));
				mBean.setLevel(Integer.parseInt(Level));
				mBean.setLng(Double.parseDouble(Lng));
				mBean.setMatchKeywords(MatchKeyWords);
				mBean.setNick_name(NickName);
				mBean.setNote(Note);
				mBean.setOnlineday(Onlineday);
				mBean.setPhone(Phone);
				mBean.setPhoto(Photo);
				mBean.setReal_name(RealName);
				mBean.setSex(Integer.parseInt(Sex));
				mBean.setShareimgs(Shareimgs);
				mBean.setSucolor(Integer.parseInt(Sucolor));
				mBean.setSuid(Suid);
				mBean.setSuperNumber(SuperNumber);
				mBean.setTel(Tel);
				mBean.setType(Integer.parseInt(Type));
				mBean.setUnreadCount(Integer.parseInt(UnreadCount));
				mBean.setUserid(Integer.parseInt(Userid));
				mBean.setVo_id(Vo_id);
				mList.add(mBean);
			}		
		} catch(Exception e) {

		}
		return mList;
	}


	public SuperFriendsBean getSuperFriendsBeanByVoId(String vo_id) {
		SuperFriendsBean mBean = new SuperFriendsBean();
		try {
			SQLiteDatabase db7 = this.getReadableDatabase();  
			//创建游标对象  
			String name = "name";
			String mSelfCode = "mSelfCode";
			Cursor cursor2 = db7.query("SuperFriendsBean",  new String[] {"Address", "ContactsType","isClicked", "IsFollowers", "LastChatTime", "Lat", "Level", "Lng", "MatchKeyWords", "ListImg", "NickName", "Note", "Onlineday", "Phone", "Photo", "RealName", "Sex", "Shareimgs", "StickyItem", "Sucolor", "Suid","SuperNumber","Tel","Type","UnreadCount", "Userid", "Vo_id", "WhiteSuperNumber"}, "Vo_id=?", new String[]{vo_id}, null, null, null);
			//利用游标遍历所有数据对象  

			if(cursor2.moveToNext()){
				String Address =  cursor2.getString(cursor2.getColumnIndex("Address"));
				String ContactsType =  cursor2.getString(cursor2.getColumnIndex("ContactsType"));
				String isClicked =  cursor2.getString(cursor2.getColumnIndex("isClicked"));

				String IsFollowers =  cursor2.getString(cursor2.getColumnIndex("IsFollowers"));
				String LastChatTime =  cursor2.getString(cursor2.getColumnIndex("LastChatTime"));
				String Lat =  cursor2.getString(cursor2.getColumnIndex("Lat"));

				String Level =  cursor2.getString(cursor2.getColumnIndex("Level"));
				String Lng =  cursor2.getString(cursor2.getColumnIndex("Lng"));
				String MatchKeyWords =  cursor2.getString(cursor2.getColumnIndex("MatchKeyWords"));

				String ListImg =  cursor2.getString(cursor2.getColumnIndex("ListImg"));
				String NickName =  cursor2.getString(cursor2.getColumnIndex("NickName"));
				String Note =  cursor2.getString(cursor2.getColumnIndex("Note"));

				String Onlineday =  cursor2.getString(cursor2.getColumnIndex("Onlineday"));
				String Phone =  cursor2.getString(cursor2.getColumnIndex("Phone"));
				String Photo =  cursor2.getString(cursor2.getColumnIndex("Photo"));

				String RealName =  cursor2.getString(cursor2.getColumnIndex("RealName"));
				String Sex =  cursor2.getString(cursor2.getColumnIndex("Sex"));
				String Shareimgs =  cursor2.getString(cursor2.getColumnIndex("Shareimgs"));

				String StickyItem =  cursor2.getString(cursor2.getColumnIndex("StickyItem"));
				String Sucolor =  cursor2.getString(cursor2.getColumnIndex("Sucolor"));
				String Suid =  cursor2.getString(cursor2.getColumnIndex("Suid"));

				String SuperNumber =  cursor2.getString(cursor2.getColumnIndex("SuperNumber"));
				String Tel =  cursor2.getString(cursor2.getColumnIndex("Tel"));
				String Type =  cursor2.getString(cursor2.getColumnIndex("Type"));

				String UnreadCount =  cursor2.getString(cursor2.getColumnIndex("UnreadCount"));
				String Userid =  cursor2.getString(cursor2.getColumnIndex("Userid"));
				String Vo_id =  cursor2.getString(cursor2.getColumnIndex("Vo_id"));


				String WhiteSuperNumber =  cursor2.getString(cursor2.getColumnIndex("WhiteSuperNumber"));

				mBean.setAddress(Address);
				mBean.setIsClicked(Integer.parseInt(isClicked));
				mBean.setIsfollower(Integer.parseInt(IsFollowers));
				mBean.setLastChatTime(Long.parseLong(LastChatTime));
				mBean.setLat(Double.parseDouble(Lat));
				mBean.setLevel(Integer.parseInt(Level));
				mBean.setLng(Double.parseDouble(Lng));
				mBean.setMatchKeywords(MatchKeyWords);
				mBean.setNick_name(NickName);
				mBean.setNote(Note);
				mBean.setOnlineday(Onlineday);
				mBean.setPhone(Phone);
				mBean.setPhoto(Photo);
				mBean.setReal_name(RealName);
				mBean.setSex(Integer.parseInt(Sex));
				mBean.setShareimgs(Shareimgs);
				mBean.setSucolor(Integer.parseInt(Sucolor));
				mBean.setSuid(Suid);
				mBean.setSuperNumber(SuperNumber);
				mBean.setTel(Tel);
				mBean.setType(Integer.parseInt(Type));
				mBean.setUnreadCount(Integer.parseInt(UnreadCount));
				mBean.setUserid(Integer.parseInt(Userid));
				mBean.setVo_id(Vo_id);
			}		
		} catch(Exception e) {

		}
		return mBean;
	}


	public long insertRecentCallsBeanList(ArrayList<RecentCallsBean> mList) {
		long i  = -1;
		try {
			SQLiteDatabase db3 = this.getWritableDatabase();
			db3.beginTransaction();
			Log.i("tag4", "1" + mList.size());
			for(Iterator<RecentCallsBean> iterator=mList.iterator();iterator.hasNext();) {
				Log.i("tag4", "2");
				RecentCallsBean mBean = iterator.next();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Address",mBean.getAddress()+"");
				contentValues.put("ContactsType",mBean.getContactsType()+"");
				contentValues.put("isClicked",mBean.getIsClicked()+"");
				contentValues.put("IsFollowers",mBean.getIsfollower()+"");
				contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Level",mBean.getLevel()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
				contentValues.put("ListImg",mBean.getmListImg()+"");
				contentValues.put("NickName",mBean.getNick_name()+"");
				contentValues.put("Note",mBean.getNote()+"");
				contentValues.put("Onlineday",mBean.getOnlineday()+"");
				contentValues.put("Phone",mBean.getPhone()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("RealName",mBean.getReal_name()+"");
				contentValues.put("Sex",mBean.getSex()+"");
				contentValues.put("Shareimgs",mBean.getShareimgs()+"");
				contentValues.put("StickyItem",mBean.getStickyItem()+"");
				contentValues.put("Sucolor",mBean.getSucolor()+"");
				contentValues.put("Suid",mBean.getSuid()+"");
				contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
				contentValues.put("Tel",mBean.getTel()+"");
				contentValues.put("Type",mBean.getType()+"");
				contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("Vo_id",mBean.getVo_id() + "");
				contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
				
				contentValues.put("callid",mBean.getCallid()+"");
				contentValues.put("user1",mBean.getUser1()+"");
				contentValues.put("user2",mBean.getUser2()+"");
				contentValues.put("calltime",mBean.getCalltime() + "");
				contentValues.put("state",mBean.getState() + "");
				contentValues.put("callnum",mBean.getCallnum() + "");
				
				i = db3.insert("RecentCallsBean", null, contentValues);
				Log.i("tag4", i + "");
			}
			db3.setTransactionSuccessful();        //����������ɹ��������û��Զ��ع����ύ
			db3.endTransaction();        //�������
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
		return i;
	}


	public long insertSuperFrined(ArrayList<SuperFriendsBean> mList) {
		long i  = -1;
		try {


			SQLiteDatabase db3 = this.getWritableDatabase();
			db3.beginTransaction();
			for(Iterator<SuperFriendsBean> iterator=mList.iterator();iterator.hasNext();) {
				SuperFriendsBean mBean = iterator.next();

				ContentValues contentValues = new ContentValues();
				contentValues.put("Address",mBean.getAddress()+"");
				contentValues.put("ContactsType",mBean.getContactsType()+"");
				contentValues.put("isClicked",mBean.getIsClicked()+"");
				contentValues.put("IsFollowers",mBean.getIsfollower()+"");
				contentValues.put("LastChatTime",mBean.getLastChatTime()+"");
				contentValues.put("Lat",mBean.getLat()+"");
				contentValues.put("Level",mBean.getLevel()+"");
				contentValues.put("Lng",mBean.getLng()+"");
				contentValues.put("MatchKeyWords",mBean.getMatchKeywords()+"");
				contentValues.put("ListImg",mBean.getmListImg()+"");
				contentValues.put("NickName",mBean.getNick_name()+"");
				contentValues.put("Note",mBean.getNote()+"");
				contentValues.put("Onlineday",mBean.getOnlineday()+"");
				contentValues.put("Phone",mBean.getPhone()+"");
				contentValues.put("Photo",mBean.getPhoto()+"");
				contentValues.put("RealName",mBean.getReal_name()+"");
				contentValues.put("Sex",mBean.getSex()+"");
				contentValues.put("Shareimgs",mBean.getShareimgs()+"");
				contentValues.put("StickyItem",mBean.getStickyItem()+"");
				contentValues.put("Sucolor",mBean.getSucolor()+"");
				contentValues.put("Suid",mBean.getSuid()+"");
				contentValues.put("SuperNumber",mBean.getSuperNumber()+"");
				contentValues.put("Tel",mBean.getTel()+"");
				contentValues.put("Type",mBean.getType()+"");
				contentValues.put("UnreadCount",mBean.getUnreadCount()+"");
				contentValues.put("Userid",mBean.getUserid()+"");
				contentValues.put("Vo_id",mBean.getVo_id() + "");
				contentValues.put("WhiteSuperNumber",mBean.getWhiteSuperNumber() + "");
				//			i = db3.insert("UCSMessage", null, contentValues);
				i = db3.insert("SuperFriendsBean", null, contentValues);

			}
			db3.setTransactionSuccessful();        //����������ɹ��������û��Զ��ع����ύ
			db3.endTransaction();        //�������
			if(db3 != null) {
				db3.close();
			}
		} catch(Exception e) {

		}
		return i;
	}


	@Override  
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {  
		//创建成功，日志输出提�? 
		Log.i(SWORD,"update a Database");  
	}  

}  